package com.example.myapplication.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.myapplication.R;
import com.example.myapplication.values.VPI;

import java.util.ArrayList;
import java.util.List;

public class fragment1 extends Fragment {

    private VPI inm;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fm1,container,false);
        ViewPager imgVP = view.findViewById(R.id.img_vp);
        inm = view.findViewById(R.id.tmd);

        List<View> viewList = new ArrayList<>();

        ImageView img = new ImageView(getContext());
        img.setBackgroundResource(R.drawable.leader);
        viewList.add(img);
        ImageView img2 = new ImageView(getContext());
        img2.setBackgroundResource(R.drawable.banner_2);
        viewList.add(img2);
        ImageView img3 = new ImageView(getContext());
        img3.setBackgroundResource(R.drawable.inm);
        viewList.add(img3);

        inm.setCount(viewList.size());
        inm.setCurrent(0);
        


        ImgAdapter imgAdapter = new ImgAdapter(viewList);
        imgVP.setAdapter(imgAdapter);
        imgVP.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }

            @Override
            public void onPageSelected(int position) {
                inm.setCurrent(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) { }
        });
        return view;
    }
}
